<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <title>添加下级代理</title>
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/theme/bootstrap.css" />
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/theme/bootstrap-responsive.css" />
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/theme/style.css" />
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/theme/jquery.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/theme/bootstrap.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/theme/ckform.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/theme/common.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/layerui/layer.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/layerui/layer.ext.js"></script>

    <style type="text/css">
        body {
            padding-bottom: 40px;
        }
        .sidebar-nav {
            padding: 9px 0;
        }

        @media (max-width: 980px) {
            /* Enable use of floated navbar text */
            .navbar-text.pull-right {
                float: none;
                padding-left: 5px;
                padding-right: 5px;
            }
        }


    </style>
</head>
<body>
<table class="table table-bordered table-hover definewidth m10">
    <tr>
        <td width="15%" style="text-align: right;" class="tableleft">主题</td>
        <td>
        <input type="hidden" name="id" id="id" value="${notice.id}">
        <input type="text" name="title" id="title" value="${notice.title}" /></td>
    </tr>
    
    <tr>
        <td style="text-align: right;" class="tableleft">内容</td>
        <td>
            <textarea id="contents" name="contents" style="width: 600px" rows="15" cols="30">
            ${notice.contents}</textarea>
        </td>
    </tr>
    <tr>
        <td class="tableleft"></td>
        <td>
            <button type="button" id="noticeSave" class="btn btn-primary" type="button">添加</button> &nbsp;&nbsp;
            <button type="button" class="btn btn-success" name="backid" id="backid">返回</button>
        </td>
    </tr>
</table>
</body>
<script>
    $(function () {       
		$('#backid').click(function(){
	    	//如果是手机,跳转到页签
	    	window.location.href="${pageContext.request.contextPath}/admin/notice_list.html";
		 });

		
		$('#noticeSave').click(function(){
			$('#usersave').attr('disabled',"true"); //添加disabled属性 
			var title = $("#title").val();
			var id = $("#id").val();
			var contents = $("#contents").val();
			if(title==""){
				layer.alert("请填写主题");
				return;
			}
			if(contents==""){
				layer.alert("请填写公告内容");
				return;
			}
			$.post("${pageContext.request.contextPath}/admin/notice_edit.html",
		            {"title":title,"id":id,"contents":contents},
		       function(data){
		            	var json = eval("("+data+")");
		            	$('#usersave').removeAttr("disabled");  //移除disabled属性 
						if(json.statusCode =='200'){
							layer.msg(json.message, {icon: 1});
							setTimeout("closewind()",2000);
						}else{
    						layer.msg(json.message, {shift: 6});
    					}
		      });
		 });
    });
    function closewind(){
    	parent.layer.close(parent.lindex);
    }
</script>
</html>